﻿using OpenApi.OAuths.Datas.DbModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenApi.OAuths.Datas.DbServices
{
    public class OAuthConsumerDbService
    {
        public static OAuthConsumerDbService Instance;

        /// <summary>
        /// consume的账户信息
        /// </summary>
        private static Dictionary<string, OAuthConsumer> OAuthCustomers;

        static OAuthConsumerDbService()
        {
            OAuthCustomers = new Dictionary<string, OAuthConsumer> { 
                      { "d0f89841d14d19cf94a619a12d3d51f9",
                            new OAuthConsumer() { ClientId = 1, ClientIdentifier = "d0f89841d14d19cf94a619a12d3d51f9", ClientSecret = "6e0da7e0a81f1392e1a893a5619ae813" }
                      },
                      { "48094e35e1cab3d125b5ea6d46f9541f",
                            new OAuthConsumer() { ClientId = 2, ClientIdentifier = "48094e35e1cab3d125b5ea6d46f9541f", ClientSecret = "52b54f322840e0cbe8d65f51601486c8" }
                       },
                      { "a7aba08d106da73dcdb12e52195eafdc", 
                          new OAuthConsumer() { ClientId = 3, ClientIdentifier = "a7aba08d106da73dcdb12e52195eafdc", ClientSecret = "3f465f066b13587bab525296698cd2f2" }
                      }
            };

            Instance = new OAuthConsumerDbService();
        }

        /// <summary>
        /// 根据指定的customerKey获取Customer对象
        /// </summary>
        /// <param name="customerKey"></param>
        /// <returns></returns>
        public OAuthConsumer GetCustomer(string customerKey)
        {
            if (OAuthCustomers.ContainsKey(customerKey))
            {
                return OAuthCustomers[customerKey];
            }
            else
            {
                return null;
            }
        }
    }
}
